package com.ds.pojo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @program: Spring-Study
 * @description:
 * @author: Dawson.Zhang
 * @create: 2020-04-04
 **/
public class Persion {

    @Autowired
    // 等价于 <bean id="persion" class="com.ds.pojo.Persion" autowire="byType"></bean>
    // @Autowired优先使用byType来装配,其次使用byName    @Qualifier 来指定某个name
    private Cat cat;
    @Resource
    // @Resource,优先使用byName,其次使用byType
    // 等价于 <bean id="persion" class="com.ds.pojo.Persion" autowire="byName"></bean>
    private Dog dog;
    private String name;

    public Persion() {
    }

    public Persion(Cat cat, Dog dog, String name) {
        this.cat = cat;
        this.dog = dog;
        this.name = name;
    }

    public Cat getCat() {
        return cat;
    }

    public void setCat(Cat cat) {
        this.cat = cat;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Persion{" +
            "cat=" + cat +
            ", dog=" + dog +
            ", name='" + name + '\'' +
            '}';
    }
}
